﻿@* 默认的主页，判断当前是否登陆，没登陆则跳转到 /authentication/login ，登陆则跳转到 /biz/index 。 *@
@using Beetle.Modules.BtAdminUI.Abstractions
@page "/"

@code {
    [Inject]
    private AuthenticationStateProvider _AuthProvider{ get; set; }
    [Inject]
    private NavigationManager _NavigationManager { get; set; }

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        var state = await _AuthProvider.GetAuthenticationStateAsync();
        // 如果已经登陆，则转向 /biz/index
        if(state.User.Identity?.IsAuthenticated is true)
        {
            _NavigationManager.NavigateTo(BtAdminUIUrlConst.URL_BIZ_INDEX);
        }
        // 如果没有登陆，则转向 /authentication/login
        else
        {
            _NavigationManager.NavigateTo(BtAdminUIUrlConst.URL_LOGIN);
        }
    }
}
